package com.work.straighttalk.presenter;

import com.hyphenate.chat.EMCallStateChangeListener;
import com.work.straighttalk.model.VideoCallMimpl;
import com.work.straighttalk.model.i.OnVideoCallListener;
import com.work.straighttalk.model.i.OnVoiceCallListener;
import com.work.straighttalk.model.i.VideoCallMI;
import com.work.straighttalk.presenter.i.VideoCallPI;
import com.work.straighttalk.ui.i.VideoCallVI;

/**
 * Created by dllo on 16/3/14.
 */
public class VideoCallPImpl implements VideoCallPI, OnVideoCallListener {
    private VideoCallVI videoCallVI;
    private VideoCallMI videoCallMI;

    public VideoCallPImpl(VideoCallVI videoCallVI) {
        this.videoCallVI = videoCallVI;
        this.videoCallMI = new VideoCallMimpl();
    }

    @Override
    public void callPhone() {
        if (videoCallVI != null) {
            videoCallVI.call();
        }
    }

    @Override
    public void mComingCall() {
        if (videoCallVI != null) {
            videoCallVI.comingCall();
        }

    }

    @Override
    public void mCinnecting() {
        if (videoCallVI != null) {
            videoCallVI.vConnectting();
        }

    }

    @Override
    public void mConnected() {
        if (videoCallVI != null) {
            videoCallVI.vConnected();
        }

    }

    @Override
    public void mAcceptend() {
        if (videoCallVI != null) {
            videoCallVI.vAccepted();
        }
    }

    @Override
    public void mDisconnnected(EMCallStateChangeListener.CallError callError) {
        if (videoCallVI != null) {
            videoCallVI.vDisconnnected(callError);
        }

    }

    @Override
    public void Call(String username, boolean isInComingCall) {
        videoCallMI.isCall(username, isInComingCall, this);
    }

    @Override
    public void setConversation() {
        videoCallMI.conversation(this);
    }

    @Override
    public void onDestroy() {
        videoCallVI = null;

    }
}
